package org.springframework.beans.factory;

/**
 *
 * 当BeanFactory设置了所有properties后，会调用afterPropertiesSet方法
 *
 * 需要被bean实现的接口，一旦bean的属性被BeanFactory设置后需要做出反应：
 如，执行自定义初始化，或者仅仅是检查是否设置了所有强制属性。

 实现InitializingBean 的可替代方式为给bean指定一个自定义的init-method，例如在一个xml bean 定义中。
 *
 * Interface to be implemented by beans that need to react once all their
 * properties have been set by a BeanFactory: for example, to perform custom
 * initialization, or merely to check that all mandatory properties have been set.
 *
 * <p>An alternative to implementing InitializingBean is specifying a custom
 * init-method, for example in an XML bean definition.
 * For a list of all bean lifecycle methods, see the BeanFactory javadocs.
 *
 * @author Rod Johnson
 * @see BeanNameAware
 * @see BeanFactoryAware
 * @see BeanFactory
 * @see org.springframework.beans.factory.support.RootBeanDefinition#getInitMethodName
 * @see org.springframework.context.ApplicationContextAware
 */
public interface InitializingBean {

	/**
	 * 当BeanFactory设置了所有properties后，会调用afterPropertiesSet方法
	 *
	 * Invoked by a BeanFactory after it has set all bean properties supplied
	 * (and satisfied BeanFactoryAware and ApplicationContextAware).
	 * <p>This method allows the bean instance to perform initialization only
	 * possible when all bean properties have been set and to throw an
	 * exception in the event of misconfiguration.
	 * @throws Exception in the event of misconfiguration (such
	 * as failure to set an essential property) or if initialization fails.
	 */
	void afterPropertiesSet() throws Exception;

}
